<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<form:form commandName="reStartTask" cssClass="form-horizontal" role="form">
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="taskName_reStart">任务名称</label>
        <div class="col-sm-4">
            <input type="text" name="taskName" id="taskName_reStart" value="${reStartTask.taskName}"
                   class="form-control"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="taskContent_reStart">任务内容</label>
        <div class="col-sm-10">
            <textarea rows="1" id="taskContent_reStart" name="taskContent"
                      class="form-control">${reStartTask.taskContent}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="industryId_reStart">指标名称</label>
        <div class="col-sm-4">
            <select name="industryId" id="industryId_reStart" class="form-control" required>
                <c:forEach items="${industries }" var="industries">
                    <option value="${industries.sysId}">${industries.indicatorName}</option>
                </c:forEach>
            </select>
        </div>
        <label class="col-sm-2 control-label no-padding-right" for="industryDate_reStart">指标时间</label>
        <div class="col-sm-4">
            <input type="text" name="industryDate" id="industryDate_reStart" value="${reStartTask.industryDate}"
                   class="form-control date-picker1" readonly/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="planStartDate_reStart">计划开始时间</label>
        <div class="col-sm-4">
            <input type="text" name="planStartDate" id="planStartDate_reStart"
                   placeholder="点击选择(默认当前时间)" class="form-control date-picker" readonly/>
        </div>
        <label class="col-sm-2 control-label no-padding-right" for="planEndDate_reStart">计划结束时间</label>
        <div class="col-sm-4">
            <input type="text" name="planEndDate" id="planEndDate_reStart"
                   placeholder="点击选择"  class="form-control date-picker" required/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="startDate_reStart">开始时间</label>
        <div class="col-sm-4">
            <input type="text" name="startDate" id="startDate_reStart"
                   placeholder="点击选择(默认当前时间)" class="form-control date-picker" readonly/>
        </div>
        <label class="col-sm-2 control-label no-padding-right" for="endDate_reStart">结束时间</label>
        <div class="col-sm-4">
            <input type="text" name="endDate" id="endDate_reStart"
                   placeholder="点击选择" value="${reStartTask.endDate}" class="form-control date-picker" readonly/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="groupCode_reStart">督查组</label>
        <div class="col-sm-4">
            <select name="groupCode" id="groupCode_reStart"
                    class="form-control <%--departments--%>" <%--multiple="multiple"--%> required>
                <c:forEach items="${supervisionList }" var="supervisionList">
                    <option value="${supervisionList.sysId}">${supervisionList.deptName}</option>
                </c:forEach>
            </select>
        </div>
        <label class="col-sm-2 control-label no-padding-right" for="deptId_reStart">责任单位</label>
        <div class="col-sm-4">
            <select name="deptId" id="deptId_reStart" class="form-control" required>
                <c:forEach items="${resDepts }" var="resDepts">
                    <option value="${resDepts.sysId}">${resDepts.deptName}</option>
                </c:forEach>
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="inspectors_reStart">督查组成员</label>
        <div class="col-sm-4">
            <input type="text" name="inspectors" id="inspectors_reStart" class="form-control"
                   value="${reStartTask.inspectors}" readonly/>
        </div>
        <label class="col-sm-2 control-label no-padding-right" for="resUser_reStart">责任人</label>
        <div class="col-sm-4">
            <input type="text" name="resUser" id="resUser_reStart" class="form-control"
                   value="${reStartTask.resUser}" readonly/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="phones_reStart">督查成员手机号</label>
        <div class="col-sm-4">
            <input type="text" name="phones" id="phones_reStart" class="form-control"
                   value="${reStartTask.phones}" readonly/>
        </div>
        <label class="col-sm-2 control-label no-padding-right" for="resPhone_reStart">责任人手机号</label>
        <div class="col-sm-4">
            <input type="text" name="resPhone" id="resPhone_reStart" class="form-control"
                   value="${reStartTask.resPhone}" readonly/>
        </div>
    </div>


    <%--任务id  隐藏--%>
    <%--<input type="text" id="taskId" value="${reStartTask.sysId}" hidden>--%>

    <form:hidden path="sysId"/>
    <%--<form:hidden path="maxVal"/>
    <form:hidden path="minVal"/> --%>
</form:form>
<script>
    /**
     * 时间选择器
     * @param el 元素
     */
    jQuery(function ($) {
        $(".date-picker").datepicker({
            inline: true,
            format: "yyyymmdd",
            autoclose: true,
            todayHighlight: true,
            language: 'cn'
        }).next().on(ace.click_event, function () {
            $(this).prev().focus();
        });

        $(".date-picker1").datepicker({
            inline: true,
            format: "yyyymm",
            autoclose: true,
            todayHighlight: true,
            language: 'cn'
        }).next().on(ace.click_event, function () {
            $(this).prev().focus();
        });

        // //涉及部门
        // $(".departments").change(function () {
        //     console.log($(".demo option:selected").text());
        // });
        // $(".departments").fSelect();

        //责任单位
        var deptIdSelected = '${reStartTask.deptId}';
        //jq选中select
        $("#deptId_reStart option[value = '" + deptIdSelected + "']").attr("selected", true);

        //督查组
        var groupCodeSelected = '${reStartTask.groupCode}';
        //jq选中select
        $("#groupCode_reStart option[value = '" + groupCodeSelected + "']").attr("selected", true);


        $("#deptId_reStart").change(function () {
            var deptId = $("#deptId_reStart").val();
            $.ajax({
                url: "/jobmanages/queryResUserByDeptId",
                type: "GET",
                dataType: "json", //返回数据形式为json
                contentType: 'application/json;charset=UTF-8',
                async: true,
                data: {"deptId": deptId},
                success: function (res) {
                    if(res != null){
                        $("#resUser_reStart").val(res.name);
                        $("#resPhone_reStart").val(res.mobile);
                    }
                }
            });
        });

        $("#groupCode_reStart").change(function () {
            var groupCode = $("#groupCode_reStart").val();
            $.ajax({
                url: "/jobmanages/querySupervisionUserByDeptId",
                type: "GET",
                dataType: "json", //返回数据形式为json
                contentType: 'application/json;charset=UTF-8',
                async: true,
                data: {"deptId": groupCode},
                success: function (res) {
                    if(res != null){
                        $("#inspectors_reStart").val(res.name);
                        $("#phones_reStart").val(res.mobile);
                    }
                }
            });
        });

    })
</script>


